<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2016/11/24
 * Time: 15:39
 */
//$path = __DIR__."/../09/fun.php";
//include_once $path;

$path = 'E:\PHP\GIT\PHPTEST\2016\11\24\1.php';
$basename = basename($path);
echo $basename.PHP_EOL;
echo "1) ".basename("/etc/sudoers.d", ".d").PHP_EOL;
echo "2) ".basename("/etc/passwd").PHP_EOL;
echo "3) ".basename("/etc/").PHP_EOL;
echo "4) ".basename(".").PHP_EOL;
echo "5) ".basename("/");
$path_parts = pathinfo($path);
var_dump($path_parts);

echo dirname($path).PHP_EOL;
echo dirname($path).'\\'.basename($path);

echo PHP_EOL.PHP_EOL;
$url = 'http://example.com/url?with=query_string';
echo basename($url.PHP_EOL); // url?with=query_string
$url = $url . '&filename_for_basename=/desired_filename.ext';
echo basename($url.PHP_EOL); // desired_filename.ext

$newfile = 'example.txt.php';

if (!copy($path, $newfile)) {
	echo "failed to copy $file...\n";
}
if(rename($newfile,"rename".$newfile)){
	echo "success".PHP_EOL;
}
sleep(1);
if(unlink("rename".$newfile)){
	echo "success".PHP_EOL;
}

$fopen = fopen( "http://localhost/phpinfo.php" ,"r");
fwrite(fopen( "localhost.html" ,"a"),fread($fopen,1024*1024));
fclose($fopen);


